﻿@model IEnumerable<RMS.Models.Problem>

@{
    ViewBag.Title = "Wait for Approve";
}
<h2>Wait for Approve Problems</h2>
<table>
    <tr>
        <th></th>
        <th>
            Problem Group
        </th>
        <th>
            Product
        </th>
        <th>
            Name
        </th>
        <th>
            Status
        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.ActionLink("Details", "Details", new { id=item.Id })
        </td>
        <td>
            @item.ProblemGroup.Name
        </td>
        <td>
            @if (item.ProductId.HasValue)
            {
                <text>
                @item.Product.Name [ @item.Product.ProductGroup.Name ]
                </text>
            }
            else
            {
                <text>
                   General Problem
                </text>
            }
        </td>
        <td>
            @item.Name
        </td>
        <td>
            @if (Roles.GetRolesForUser().Any(x => x == "Moderator"))
            {
                <text>[ @Html.ActionLink("Approve", "Approve", new { id = item.Id }) ]
                [ @Html.ActionLink("Decline","Decline",new{id=item.Id}) ]</text>
            }
            else
            {
                <text>You aren't moderator.</text>
            }
        </td>
    </tr>
}

</table>

<h2>Wait for Approve Best Practice</h2>
<table>
    <tr>
        <th>
            Name
        </th>
        <th>
            Problem
        </th>
        <th>
            Product
        </th>
        <th>
            Create By
        </th>
        <th>
            Status
        </th>
    </tr>

@foreach (var item in ViewData["bestPractices"] as IEnumerable<RMS.Models.BestPractice>)
{
    <tr>
        <td>
            @item.Name
        </td>
        <td>
            @item.Problem.Name [@item.Problem.ProblemGroup.Name]
        </td>
        <td>
            @item.Problem.Product.Name [@item.Problem.Product.ProductGroup.Name]
        </td>
        <td>
            @item.CreateUser.Name [@item.CreateUser.Company.Name]
        </td>
        <td>
            @if (Roles.GetRolesForUser().Any(x => x == "Moderator"))
            {
                <text>[ @Html.ActionLink("Approve", "Approve","BestPractice", new { id = item.Id },null) ]
                [ @Html.ActionLink("Decline","Decline","BestPractice",new{id=item.Id},null) ]</text>
            }
            else
            {
                <text>You aren't moderator.</text>
            }
        </td>
    </tr>
}

</table>
